<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sitemesh" uri="http://www.opensymphony.com/sitemesh/decorator" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>


<script type="text/javascript">
    $(document).ready(function () {
        $("#cacheList").jqGrid({
            datatype: "json",
            url: "${ctx}/system/getCache",
            mtype: "POST",
            width: "100%",
            height: "100%",
            colNames: ['缓存大类名称', '缓存名', '创建时间', '过期时间', '命中次数', '最后访问时间', '最后更新时间'],
            colModel: [
                {name: 'cacheName', index: 'cacheName', search: false, sortable: false, editable: false},
                {name: 'cacheKeyName', index: 'cacheKeyName', sortable: false},
                {name: 'creationTime', index: 'creationTime', sortable: false},
                {name: 'expirationTime', index: 'expirationTime', sortable: false},
                {name: 'hitCount', index: 'hitCount', sortable: false},
                {name: 'lastAccessTime', index: 'lastAccessTime', sortable: false},
                {name: 'lastUpdateTime', index: 'lastUpdateTime', sortable: false}
            ],
            rowNum: 10,
            rowList: [10, 20, 30],
            pager: '#pager',
            imgpath: 'images',
            sortname: 'cacheName',
            viewrecords: true,
            sortorder: "desc",
            autowidth: true,
            jsonReader: {
                repeatitems: false,
                id: "cacheName"
            },
            caption: "缓存列表"
        });

        $("#cache-dialog-form").dialog({
            autoOpen: false,
            height: 250,
            width: 300,
            modal: true,
            buttons: {
                "确定": function () {
                    $("#cacheForm").attr("action", "${ctx}/system/cache/clean");
                    $("#cacheForm").submit();
                },
                "取消": function () {
                    $(this).dialog("close");
                }
            },
            close: function () {
            }
        });

    });

    function cleanAll() {
        $("#cache-dialog-form").dialog("open");
    }
</script>

<div class="panel_container">
    <div class="panel">
        <div class="panel_header">
            <div><h2>系统缓存管理</h2></div>

        </div>
        <div class="panel_body">

            <div>
                <table id="cacheList"></table>
                <div id="pager"></div>
            </div>

        </div>

        <div class="panel_footer">
            <div>
                <p>提醒：缓存包括具体项目中定义的缓存和框架缓存(框架一级和二级缓存)，出于安全考虑，以上只显示具体项目中定义的缓存，框架缓存不在显示之列。</p>
                <br/>
            </div>
            <div>
                <input type="button" class="btn_blue" value="清除所有缓存" onclick="cleanAll()">
            </div>
        </div>
    </div>
</div>

<div id="cache-dialog-form" title="确定" style="display: none;">
    清除系统所有缓存？请放心，清理缓存不会导致系统崩溃，缓存会在下次运行的时候自动创建。
</div>

<form name="cacheForm" id="cacheForm" action="" method="POST">
    <input type="hidden" name="mode" id="mode" value="cleanAll"/>
    <input type="hidden" name="cacheName" id="cacheName"/>
    <input type="hidden" name="cacheKey" id="cacheKey"/>
</form>